<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Api_Model_Tour
{
	private $tour_id;
	private $tour_name;
	private $description;
	private $start_date;
	private $end_date;
	private $limited_user;
	private $is_closed;
	private $created_time;
	private $updated_time;

	public function __construct($tour_row = null) {
		if(!is_null($tour_row) && $tour_row instanceof Zend_Db_Table_Row) {
			$this->tour_id = $tour_row->tour_id;
			$this->tour_name = $tour_row->tour_name;
			$this->description = $tour_row->description;
			$this->start_date = $tour_row->start_date;
			$this->end_date = $tour_row->end_date;
			$this->limited_user = $tour_row->limited_user;
			$this->is_closed = $tour_row->is_closed;
			$this->created_time = $tour_row->created_time;
			$this->updated_time = $tour_row->updated_time;
		}
	}

	public function __set($name, $value) {
		switch($name) {
			case 'tour_id':
				if(!is_null($this->tour_id)) {
					throw new Exception('Cannot update tour\'s id');
				}
				break;
			case 'tour_name':
				if(!is_null($this->tour_name)) {
					throw new Exception('Cannot update tour name');
				}
				break;
			case 'description':
				if(!is_null($this->description)) {
					throw new Exception('Cannot update description');
				}
				break;
			case 'start_date':
				if(!is_null($this->start_date)) {
					throw new Exception('Cannot update start date');
				}
				break;
			case 'end_date':
				if(!is_null($this->end_date)) {
					throw new Exception('Cannot update end date');
				}
				break;
			case 'limited_user':
				if(!is_null($this->limited_user)) {
					throw new Exception('Cannot update limited user');
				}
				break;
			case 'is_closed':
				if(!is_null($this->is_closed)) {
					throw new Exception('Cannot update is_closed');
				}
				break;
			case 'created_time':
				if(!is_null($this->created_time)) {
					throw new Exception('Cannot update created_time');
				}
				break;
			case 'updated_time':
				if(!is_null($this->updated_time)) {
					throw new Exception('Cannot update updated_time');
				}
				break;
		}
		$this->$name = $value;
	}

	public function __get($name) {
		return $this->$name;
	}
}

